import java.util.concurrent.*;

public class Demo1 {
    public static void main(String[] args) {
        ThreadPoolExecutor executor = new ThreadPoolExecutor(5,
                10,
                60,TimeUnit.SECONDS,
                new PriorityBlockingQueue<>(100),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.DiscardOldestPolicy());
    }
    public static void main1(String[] args) throws InterruptedException {
        CountDownLatch downLatch = new CountDownLatch(8);
        for (int i = 0; i < 8; i++) {
            int finalI = i;
            Thread t1 = new Thread(() -> {
                System.out.println("运动员"+finalI+"起跑");
                try {
                    Thread.sleep(1000);
                    System.out.println("运动员"+finalI+"跑向终点");
                    downLatch.countDown();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            });
            t1.start();
        }
        downLatch.await();
        System.out.println("所有运动员跑完了");
    }
}
